package com.example.weather.entity;

import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;

import com.example.weather.utils.SexConverter;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;

/**
 * <p>
 * 用户信息
 * </p>
 *
 * @author author
 * @since 2025-02-06
 */
@Data
@EqualsAndHashCode(callSuper = false)
//@Accessors(chain = true)
@TableName("user")
@ApiModel(value="User对象", description="用户信息")
@AllArgsConstructor
@NoArgsConstructor
@ExcelIgnoreUnannotated
public class User  extends baseEntity implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "主键uuid")
    @TableId(value = "id", type = IdType.AUTO)
    @ExcelProperty(value = "序号", index = 0)
    @ColumnWidth(8)
    private Integer id;

    @ApiModelProperty(value = "姓名")
    @ExcelProperty(value = "姓名", index = 1)
    @ColumnWidth(12)
    @NotBlank(message = "姓名不能为空")
    private String name;

    @ApiModelProperty(value = "用户名")
    @ExcelProperty(value = "用户名", index = 2)
    @ColumnWidth(16)
    @NotBlank(message = "用户名不能为空")
    private String userName;

    @ApiModelProperty(value = "密码")
    @ExcelProperty(value = "密码", index = 3)
    @ColumnWidth(16)
    @NotBlank(message = "密码不能为空")
    private String password;

    @ApiModelProperty(value = "性别")
//    @ExcelProperty(value = "性别", index = 4,converter = SexConverter.class)
    @ExcelProperty(value = "性别", index = 4)
    @ColumnWidth(8)
    private Integer sex;

    @ApiModelProperty(value = "联系方式")
    @ExcelProperty(value = "联系方式", index = 5)
    @ColumnWidth(16)
    @Pattern(regexp = "^[1][3,4,5,7,8][0-9]{9}$",message = "联系电话格式不正确!")
    private String phone;

    @ApiModelProperty(value = "身份证号")
    @ExcelProperty(value = "身份证号", index = 6)
    @ColumnWidth(20)
    @Pattern(regexp = "^\\d{15}$|^\\d{17}[0-9Xx]$",message = "身份证格式不正确!")
    private String idNumber;

}
